package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicSubjectsDAO;
import com.cssy.xxkj.basic.entity.BasicSubjectsDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2013-06-21
 */
public class BasicSubjectsDAOImpl extends SqlMapClientDaoSupport implements BasicSubjectsDAO {

    /**
     * 插入数据
     * @param basicAreaDO
     * @return 插入数据的主键
     */
    public String insertBasicSubjectsDO(BasicSubjectsDO basicSubjectsDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicSubjects.insert", basicSubjectsDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicAreaDO
     * @return 查出的记录数
     */
    public Integer countBasicSubjectsDOByExample(BasicSubjectsDO basicSubjectsDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicSubjects.countByDOExample", basicSubjectsDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicAreaDO
     * @return 受影响的行数
     */
    public Integer updateBasicSubjectsDO(BasicSubjectsDO basicSubjectsDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicSubjects.update", basicSubjectsDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicAreaDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicSubjectsDO> findListByExample(BasicSubjectsDO basicSubjectsDO) throws DataAccessException {
        List<BasicSubjectsDO> list = getSqlMapClientTemplate().queryForList("BasicSubjects.findListByDO", basicSubjectsDO);
        return list;
    }

    /**
     * 根据主键获取basicAreaDO
     * @param id
     * @return basicAreaDO
     */
    public BasicSubjectsDO findBasicSubjectsDOByPrimaryKey(String id) throws DataAccessException {
    	BasicSubjectsDO basicSubjectsDO = (BasicSubjectsDO) getSqlMapClientTemplate().queryForObject("BasicSubjects.findByPrimaryKey", id);
        return basicSubjectsDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicSubjectsDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicSubjects.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
	public List<BasicSubjectsDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicSubjectsDO> list = getSqlMapClientTemplate().queryForList("BasicSubjects_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicSubjects_ex.count", scs);
		return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicSubjects_ex.deleteBizRemoved", id);
		return count;
	}
}